package com.yun.userdemo.service.impl;

import com.yun.userdemo.beans.User;
import com.yun.userdemo.dao.UserDao;
import com.yun.userdemo.service.UserService;
import com.yun.userdemo.utils.ListToListMap;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.*;

@Service
public class UserServiceImpl implements UserService {

    @Autowired
    private UserDao userDao;

    /**
     * 添加用户
     * @param user
     * @return
     */
    @Override
    public int addUser(User user) {
        return userDao.addUser(user);
    }

    /**
     * 修改用户
     * @param user
     * @return
     */
    @Override
    public int updateUser(User user) {
        return userDao.updateUser(user);
    }

    /**
     * 删除用户
     * @param id
     * @return
     */
    @Override
    public int deleteUserById(Integer id) {
        return userDao.deleteUserById(id);
    }

    /**
     * 根据用户id查询用户
     * @param id
     * @return
     */
    @Override
    public User queryUserById(Integer id) {
        return userDao.queryUserById(id);
    }

    /**
     * 查询所有用户
     * @return
     */
    @Override
    public List<User> queryAllUser() {
        List<User> users = userDao.queryAllUser();
        return users;
    }
}
